package com.renaud.solr.beanTest;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.google.common.base.Objects;

import fr.insee.solr.model.JsonFieldStrategy;
import fr.insee.solr.model.annotation.SolrField;
import fr.insee.solr.model.annotation.SolrFields;

public class AvisClient {

	/*
	 * <field name="produit" type="string" indexed="true" required="false" />
	 * <field name="speudo" type="string" indexed="true" />
	 * <field name="stats" type="string" indexed="false" />
	 * <field name="achats" type="string" indexed="true" multiValued="true" />
	 * <field name="souhaits" type="string" indexed="true" multiValued="true" />
	 * <field name="note" type="int" indexed="true" />
	 * <field name="avis" type="text_fr" indexed="true" />
	 * <field name="commentaires" type="text_fr" indexed="true" multiValued="true" />
	 * <field name="dateAchat" type="date" indexed="true" />
	 * <field name="parrain" type="string" indexed="true" stored="false"/>
	 * <field name="parrainJson" type="string" indexed="false" />
	 */

	@SolrField(fieldName = "id")
	private Long id;
	@SolrField(fieldName = "produit", fieldStrategy = JsonFieldStrategy.class)
	private Produit produit;
	@SolrFields(fields = { @SolrField(fieldName = "speudo", beanName = "client.speudo"), @SolrField(fieldName = "stats", beanName = "client.stats", fieldStrategy = JsonFieldStrategy.class) })
	private Client client;
	@SolrField(fieldName = "achats", multivalued = true, fieldStrategy = JsonFieldStrategy.class)
	private List<Produit> derniersAchats = new ArrayList<>();
	@SolrField(fieldName = "souhaits", beanName = "listeSouhaits.libelle", multivalued = true)
	private List<Produit> listeSouhaits = new ArrayList<Produit>();
	@SolrField(fieldName = "note")
	private Integer note;
	@SolrField(fieldName = "avis")
	private String avis;
	@SolrField(fieldName = "commentaires", multivalued = true)
	private Set<String> commentaire = new TreeSet<String>();
	@SolrField(fieldName = "dateAchat")
	private Date date;
	@SolrFields(fields = { @SolrField(fieldName = "parrainJson", fieldStrategy = JsonFieldStrategy.class), @SolrField(fieldName = "parrain", beanName = "parrain.speudo", read = false) })
	private Client parrain;
	@SolrField(fieldName = "stats", fieldStrategy = JsonFieldStrategy.class, index = false)
	private StatClient stats;
	@SolrField(fieldName = "followers", beanName = "followers.followers", nestedList = true)
	private Client followers;

	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (getClass() != o.getClass()) {
			return false;
		}
		final AvisClient other = (AvisClient) o;
		return Objects.equal(this.id, other.id) && Objects.equal(this.produit, other.produit) && Objects.equal(this.client, other.client) && Objects.equal(this.derniersAchats, other.derniersAchats) && Objects.equal(this.listeSouhaits, other.listeSouhaits) && Objects.equal(this.note, other.note) && Objects.equal(this.avis, other.avis) && Objects.equal(this.date, other.date) && Objects.equal(this.parrain, other.parrain) && Objects.equal(this.stats, other.stats);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Produit getProduit() {
		return produit;
	}

	public void setProduit(Produit produit) {
		this.produit = produit;
	}

	public Client getClient() {
		return client;
	}

	public List<Produit> getDerniersAchats() {
		return derniersAchats;
	}

	public void setDerniersAchats(List<Produit> derniersAchats) {
		this.derniersAchats = derniersAchats;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Integer getNote() {
		return note;
	}

	public void setNote(Integer note) {
		this.note = note;
	}

	public String getAvis() {
		return avis;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setAvis(String avis) {
		this.avis = avis;
	}

	public Set<String> getCommentaire() {
		return commentaire;
	}

	public void setCommentaire(Set<String> commentaire) {
		this.commentaire = commentaire;
	}

	public Client getParrain() {
		return parrain;
	}

	public StatClient getStats() {
		return stats;
	}

	public void setStats(StatClient stats) {
		this.stats = stats;
	}

	public void setParrain(Client parrain) {
		this.parrain = parrain;
	}

	public List<Produit> getListeSouhaits() {
		return listeSouhaits;
	}

	public void setListeSouhaits(List<Produit> listeSouhaits) {
		this.listeSouhaits = listeSouhaits;
	}

	public Client getFollowers() {
		return followers;
	}

	public void setFollowers(Client followers) {
		this.followers = followers;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
	}

}
